package com.sbtr.controller.classify;

import com.sbtr.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sbtr.exception.BDException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.sbtr.common.PageDto;
import com.sbtr.business.classify.entity.AlgoCondition;
import com.sbtr.business.classify.dto.AlgoConditionDto;
import com.sbtr.business.classify.service.AlgoConditionService;
import org.springframework.web.bind.annotation.RestController;
import com.sbtr.controller.common.CommonController;

/**
 * 裁剪条件 前端控制器
 *
 * @author dgl
 * @since 2023-09-01
 */
@RestController
@RequestMapping("/algoCondition")
@Api(tags = "裁剪条件")
public class AlgoConditionController extends CommonController<AlgoCondition,AlgoConditionService> {

    @GetMapping("/pageList")
    @ApiOperation(httpMethod = "GET", value = "分页列表")
    public Response<PageDto<AlgoCondition>> pageList(AlgoConditionDto algoConditionDto){
        return Response.success(u.pageList(algoConditionDto));
    }

    @PostMapping("/save")
    @ApiOperation(httpMethod = "POST", value = "保存")
    public Response<AlgoCondition> save(@RequestBody AlgoCondition algoCondition){
        algoCondition.setId(null);
        if(algoCondition.insert()){
            return Response.success(algoCondition);
        }else throw new BDException("保存失败");
    }

}

